package cn.edu.xmu.orderpayment.order.model.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Chencheng Liao 22920192204238
 * @date 2021/12/28
 */
public enum OnSaleType {
    NOACTIVITY(0, "无活动"),
    SECKILL(1, "秒杀"),
    GROUPON(2, "团购"),
    PRESALE(3, "预售");


    private static final Map<Integer, OnSaleType> TYPE_MAP;

    static {
        TYPE_MAP = new HashMap();
        for (OnSaleType enum1 : values()) {
            TYPE_MAP.put(enum1.code, enum1);
        }
    }

    private int code;
    private String description;

    OnSaleType(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public static OnSaleType getTypeByCode(Integer code) {
        return TYPE_MAP.get(code);
    }

    public Integer getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

}
